package com.jacobson.huobi.common.constants

object PrioritySetConstant {

    //正常满足
    const val SATISFY_01 = 0x00000001L
    const val SATISFY_02 = 0x00000002L
    const val SATISFY_03 = 0x00000004L
    const val SATISFY_04 = 0x00000008L
    const val SATISFY_05 = 0x00000010L

    //之前满足,但实时为不满足,有变为不满足的情况
    const val SATISFY_DANGER_01 = 0x01000000L
    const val SATISFY_DANGER_02 = 0x02000000L
    const val SATISFY_DANGER_03 = 0x03000000L
    const val SATISFY_DANGER_04 = 0x08000000L
    const val SATISFY_DANGER_05 = 0x10000000L

    //之前为不满足,但实时为满足,有变成满足的希望
    const val SATISFY_HOPE_01 = 0x00010000L
    const val SATISFY_HOPE_02 = 0x00020000L
    const val SATISFY_HOPE_03 = 0x00040000L
    const val SATISFY_HOPE_04 = 0x00080000L
    const val SATISFY_HOPE_05 = 0x00100000L

    /**
     * 不分类型获取级别
     */
    fun getSetLevelInDiffType(value: Long): Int {
        if (((value and SATISFY_01) == SATISFY_01)
            || ((value and SATISFY_DANGER_01) == SATISFY_DANGER_01)
            || ((value and SATISFY_HOPE_01) == SATISFY_HOPE_01)) {
            return 1
        }else if (((value and SATISFY_02) == SATISFY_02)
            || ((value and SATISFY_DANGER_02) == SATISFY_DANGER_02)
            || ((value and SATISFY_HOPE_02) == SATISFY_HOPE_02)) {
            return 2
        }else if (((value and SATISFY_03) == SATISFY_03)
            || ((value and SATISFY_DANGER_03) == SATISFY_DANGER_03)
            || ((value and SATISFY_HOPE_03) == SATISFY_HOPE_03)) {
            return 3
        }else if (((value and SATISFY_04) == SATISFY_04)
            || ((value and SATISFY_DANGER_04) == SATISFY_DANGER_04)
            || ((value and SATISFY_HOPE_04) == SATISFY_HOPE_04)) {
            return 4
        }else if (((value and SATISFY_05) == SATISFY_05)
            || ((value and SATISFY_DANGER_05) == SATISFY_DANGER_05)
            || ((value and SATISFY_HOPE_05) == SATISFY_HOPE_05)) {
            return 5
        }else {
            return 999
        }

    }

    fun isPrioritySetDanger(value: Long) :Boolean {
        if (((value and SATISFY_DANGER_01) == SATISFY_DANGER_01) || ((value and SATISFY_DANGER_02) == SATISFY_DANGER_02) ||((value and SATISFY_DANGER_03) == SATISFY_DANGER_03)
            || ((value and SATISFY_DANGER_04) == SATISFY_DANGER_04) ||((value and SATISFY_DANGER_05) == SATISFY_DANGER_05)) {
            return true
        }
        return false
    }
}